varying vec3 pos;
varying float depth;
varying vec3 norm;

void main()
{
	depth = vec3(gl_ModelViewProjectionMatrix * gl_Vertex).z;
	pos = vec3(gl_Vertex);
	norm = gl_Normal;

	// Texture offset for selecting side textures
	gl_TexCoord[0] = gl_MultiTexCoord0;
	
	// Data texture coordinate for selecting block type
    gl_TexCoord[1] = vec4((floor(pos) - (sign(norm) * vec3(0.5, 0.5, 0.5))) / 64.0, 1.0);
//    gl_TexCoord[1] = vec4(floor(pos) / 64.0, 1.0);

	// Data texture coordinate for selecting adjacent block type
    gl_TexCoord[2] = vec4((floor(pos) + (sign(norm) * vec3(0.5, 0.5, 0.5))) / 64.0, 1.0);

	gl_Position = ftransform();
}
